package com.chinasoft.mapper;

import com.chinasoft.pojo.GoodCount;
import com.chinasoft.pojo.TeacherCount;
import com.chinasoft.pojo.Usergood;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodlistMapper {
    @Select("select * from usergood where username = #{username}")
    List<Usergood> find(@Param("username") String username);
    @Insert("insert into usergood (username,name,goodid,goodname,money,startime,endtime) values " +
            " (#{username},#{name},#{goodid},#{goodname},#{money},#{startime},#{endtime})")
    int insert(Usergood usergood);
    @Update("UPDATE usergood SET del = #{del} WHERE id = #{id}")
    int updateDel(@Param("id") Integer id, @Param("del")String del);

    @Select("SELECT DATE_FORMAT(STR_TO_DATE(startime,'%Y/%m/%d %H:%i'), '%Y/%m') AS month, " +
            " goodname, COUNT(*) AS total_type " +
            " FROM usergood " +
            " GROUP BY month,goodname " +
            " ORDER BY month,goodname ")
    List<GoodCount> findlist();
}
